/**
 * <p>Copyright (c) 2017 深圳市鹏途交通科技有限公司 </p>
 * <p>				   All right reserved. 		     </p>
 * 
 * <p>项目名称 ： 	         </p>
 * <p>创建者   :	win7 
 * 
 * <p>描   述  :   MoneyOverViewServiceImpl.java for com.pengtu.gsj.service.impl.jhgl    </p>
 * 
 * <p>最后修改 : $: 2017年6月29日-下午2:03:48 v 1.0.0	 win7   $ </p>
 * 
*/

package com.pengtu.gsj.service.impl.jhgl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.pengtu.gsj.dao.base.Page;
import com.pengtu.gsj.dao.base.QueryFilter;
import com.pengtu.gsj.dao.jhgl.MoneyOverViewDao;
import com.pengtu.gsj.entity.app.Attachment;
import com.pengtu.gsj.entity.jhgl.MoneyOverView;
import com.pengtu.gsj.service.jhgl.MoneyOverViewService;
import com.pengtu.gsj.service.system.SystemManageService;

/**
 * 
 * MoneyOverViewServiceImpl
 * 
 * 2017年6月29日 下午2:03:48
 * 
 * @version 1.0.0
 * 
 */
@Transactional
@Service
public class MoneyOverViewServiceImpl implements MoneyOverViewService {
	@Autowired
	private MoneyOverViewDao moneyOverViewDao;
	
	@Autowired
	private SystemManageService systemManageService;
	
	@Override
	public List<MoneyOverView> getMoneyOverViews(QueryFilter queryFilter) {
		return moneyOverViewDao.find(queryFilter);
	}

	@Override
	public Page<MoneyOverView> findMoneyOverView(Page<MoneyOverView> page, QueryFilter queryFilter) {
		return moneyOverViewDao.findPage(page, queryFilter);
	}

	@Override
	public MoneyOverView getMoneyOverView(String id) {
		return moneyOverViewDao.get(id);
	}

	@Override
	public void saveMoneyOverView(MoneyOverView moneyOverView) {
		moneyOverViewDao.save(moneyOverView);
	}

	@Override
	public void delateMoneyOverView(MoneyOverView moneyOverView) {
		if(moneyOverView.getAttachments() != null){
			for(Attachment attachment : moneyOverView.getAttachments()){
				systemManageService.deleteAttachment(attachment);
			}
		}
		moneyOverViewDao.delete(moneyOverView);
	}
	/**
	 * 获取养护资金中的所有养护资金项目
	 */
	@Override
	public List<MoneyOverView> getMoneyOverViewGroupByProjectName(QueryFilter queryFilter){
		return moneyOverViewDao.find(queryFilter);
	}
}
